package kr.hkit.PowerJava.chapter12;

import java.util.Arrays;
import java.util.Comparator;

import kr.hkit.PowerJava.chapter12.InterPackage.Comparable;
 class Student implements Comparable{
	private String stdName;
	private double gpa;
	public Student(String stdName,double gpa){
		this.stdName = stdName;
		this.gpa = gpa;
		}
	public String getStdName() {
		return stdName;
	}
public String setStdName(){
	return stdName;
}
	
	public double getGpa() {
		return gpa;
	}
public double setGpa(){
	return gpa;
}
	
	@Override
	public String toString() {
		return String.format("[%s, %s]", stdName, gpa);
	}
	public int compareTo(Student o) {
		
		return 0;
	}
	@Override
	public int compareTo(Object other) {
		// TODO Auto-generated method stub
		return 0;
	}
	


}

public class SortTest {
   public static void main(String[] args) {
	int[]arr = {5,6,7,8,1,2,3,4};
	
	prnArr(arr);
    Arrays.sort(arr);
    prnArr(arr);
    
    Student[] arrStd = new Student[4];
    arrStd[0] = new Student("홍길동", 3.39);
    arrStd[1] = new Student("임꺽정", 4.21);
    arrStd[2] = new Student("황진이", 2.19);
    arrStd[3] = new Student("김태희", 4.4);
    
   prnArr(arrStd);
 //  Arrays.sort(arrStd);
   Comparator<Student> comp = new Comparator<Student>(){
	   public int compare(Student o1, Student o2){
	   return o1.getStdName().hashCode()-o2.getStdName().hashCode();
   }
   };
	   Arrays.sort(arrStd,comp );
   
   prnArr(arrStd);
   }
public static void prnArr(Student[]arrStd) {
	for(Student s: arrStd){
		System.out.print(s+"\t");
		}
System.out.println();
}
   
   private static void prnArr(int[] arr){
	for(int e:arr){
		System.out.printf("%2d",e);
	}
System.out.println();
   }


}
